﻿@{
    ViewBag.Title = "Leave";
    Layout = "~/Views/Shared/_Layout.cshtml";
}


@using Common.BaseLibrary.Authorization
@using DepartmentWork.Model
@model DepartmentWork.Model.ProjectDeskLeaveViewModel



<div class="page-header">
    <div class="pull-left">
        <ol class="breadcrumb visible-sm visible-md visible-lg">
            <li><a href="index.html"><i class="icon fa fa-home"></i>主页</a></li>
            <li class="active"><a href="#"><i class="fa fa-envelope"></i>请假管理</a></li>
        </ol>
    </div>
</div>
@{
    if (ViewBag.Flag == "True")
    {
    <div class="alert alert-success">
        <button type="button" class="close" data-dismiss="alert">×</button>
        <strong>&emsp;@ViewBag.FlagInfo！</strong>
    </div>
    }
    if (ViewBag.Flag == "False")
    {
    <div class="alert alert-danger">
        <button type="button" class="close" data-dismiss="alert">×</button>
        <strong>&emsp;操作失败！</strong> @ViewBag.FlagInfo
    </div>
    }
}
<style>
   ul>.active {
       font-weight:bold
   }
   .bootstrap-select  {
       width: 100%;
   }
    
</style>

<script>
    function selcet() {
        //alert('a');
        //debugger;
        document.getElementById("YesSelcet").style.display = "";
        document.getElementById("NoSelcet").style.display = "none";
        $.ajax({
            type: "POST",
            //url: "/KSManager/DepartmentArea/Leave/SelcetS",
            url:'@Url.Action("SelcetS","Leave",new{area="DepartmentArea"})',
            data: "NameId=" + $("#select_ID").val() + "&&BTime=" + $("#selcet_text_BTime_id").val() + "&&DTime=" + $("#selcet_text_DTime_id").val(),
            error: function () { alert("服务器出错！"); },
            success: function (data) {
               
                createShowingTable(data);
           
            }
        });
    }

 
    function createShowingTable(data)
    {
        var tableStr = "<hr style='width:100%; height:2px;border:none;border-top:2px solid #185598;'/>" +"<table class='table table-hover'>";
        tableStr = tableStr
        +"<thead>"
        +"<tr>"
        +"<th style='text-align: center'>请假人</th>"
        +"<th style='text-align: center'>申请时间</th>"
        +"<th style='text-align: center'>请假起止时间</th>"
        +"<th style='text-align: center'>请假天数</th>"
        +"<th style='text-align: center'>请假类别</th>"
        +"<th style='text-align: center'>本月请假次数</th>"
        +"<th style='text-align: center'>审批结果</th>"
        +"<th style='text-align: center'>审批人</th>"
        +"</tr>"
        +"</thead>";
        var len = data.length;
        for (var i = 0; i < len; i++)
        {
            tableStr = tableStr
            + "<tr>"
            + "<td style='text-align: center'>" + data[i]["leave_name"] + "</td>"
            + "<td style='text-align: center'>" + data[i]["leave_time_selcet"] + "</td>"
            + "<td style='text-align: center'>" + data[i]["leave_day"] + "</td>"
            + "<td style='text-align: center'>" + data[i]["leave_howmanydays"] + "</td>"
            + "<td style='text-align: center'>" + data[i]["leave_classes"] + "</td>"
            + "<td style='text-align: center'>" + data[i]["leave_quantity"] + "</td>"
            + "<td style='text-align: center'>" + data[i]["leave_approverresult"] + "</td>"
            + "<td style='text-align: center'>" + data[i]["leave_approver"] + "</td>"
            + "</tr>";
        }
        $("#xxx").html(tableStr);
    }

</script>








<div class="row">
    <div class="col-lg-12">
        <div class="panel">
            <div class="panel-heading bk-bg-primary">
                <h6><i class="fa fa-table red"></i><span class="break"></span>请假列表</h6>
                @{
                    if (ViewBag.anonymity == true)
                    {
                    <div class="panel-actions">
                        <a data-toggle="modal" data-target="#myModal" class="bk-margin-5 btn btn-default  btn-sm" style="background-color: #ECEDF0">&nbsp;&nbsp;我要请假&nbsp;&nbsp;</a>
                    </div>
                    }
                }

            </div>
            <div class="panel-body">
                <div class="tabs">
                    <ul class="nav nav-tabs">
                        @{
                            if (ViewBag.anonymity == true)
                            {
                            <li class="active">
                                <a href="#oneself" style="color:black" data-toggle="tab">个人请假记录</a>
                            </li>
                            }
                        }
                        @{
                            if (ViewBag.IsAdmin == true && ViewBag.anonymity == true)
                            {
                             <li class="">
                                <a href="#all" style="color:black" data-toggle="tab">全员请假记录统计</a>
                            </li>
                            <li class="">
                                <a href="#dai" style="color:black" data-toggle="tab">待审批</a>
                            </li>
                            }
                        }
                         @{
                             if (ViewBag.IsAdmin == true && ViewBag.anonymity == false)
                             {
                            <li class="">
                                <a href="#all" style="color:black" data-toggle="tab">全员加班记录与统计</a>
                            </li>
                             }
                        }
                    </ul>
                    <div class="tab-content">
                        @if (ViewBag.anonymity == true)
                        {
                            <div id="oneself" class="tab-pane active">
                                <div class="panel-body">
                                    <div class="table-responsive">
                                        <table class="table table-hover">
                                            <thead>
                                                <tr>
                                                    <th style="text-align: center">请假人</th>
                                                    <th style="text-align: center">申请时间</th>
                                                     <th style="text-align: center">请假起止时间</th>
                                                    <th style="text-align: center">请假天数</th>
                                                    <th style="text-align: center">请假类别</th>
                                               
                                                    <th style="text-align: center">审批结果</th>
                                                    <th style="text-align: center">审批人</th>
                                                    <th style="text-align: center">操作</th>
                                                </tr>
                                            </thead>
                                            <tbody>

                                                @if (ViewBag.ownLeave != null)
                                                {
                                                    foreach (ProjectDeskLeaveViewModel item in ViewBag.ownLeave)
                                                    {
                                                    <tr>
                                                        <td style="text-align: center ;color: black">@item.leave_name</td>
                                                        <td style="text-align: center;color: black">@item.leave_time.ToString("yyyy-MM-dd")</td>
                                                        <td style="text-align: center;color: black">@item.leave_day</td>
                                                        <td style="text-align: center;color: black">@item.leave_howmanydays</td>
                                                        <td style="text-align: center;color: black">@item.leave_classes</td>
                                                  
                                                 
                                                        @if (item.leave_approverresult == "0")
                                                        {
                                                          
                                                            <td style="text-align: center;color: black">等待审批</td>
                                                              <td></td>
                                                            <td style="text-align: center;color: black">

                                                                <a onclick="getid('@item.leave_id')" data-toggle="modal" data-target="#q_bianji" style="color:blue">&nbsp;&nbsp;编辑&nbsp;&nbsp;</a>
                                                                <a onclick="deleteid('@item.leave_id')" data-toggle="modal" data-target="#Delete" style="color:red">&nbsp;&nbsp;删除&nbsp;&nbsp;</a>
                                                            </td>
                                                            
                                                        }
                                                         @if (item.leave_approverresult == "1")
                                                         {
                                                           
                                                            <td style="text-align: center;color: black">通过</td>
                                                             <td style="text-align: center;color: black">@item.leave_approver</td>
                                                            <td></td>
                                                         }
                                                           @if (item.leave_approverresult == "3")
                                                           {
                                                                <td style="text-align: center;color: black">被驳回</td>
                                                             <td style="text-align: center;color: black">@item.leave_approver</td>
                                                            <td></td>
                                                           }
                                                    </tr>
                                                    }
                                                }


                                            </tbody>
                                        </table>
                                    </div>
                                    <div class="bk-margin-5 btn-group" style="float: right">
                                        @Html.ShowPageNavigate((int)ViewData["pageIndexExecute"], (int)ViewData["pageSizeExecute"], (int)ViewData["totalExecute"])
                                    </div>
                                </div>
                            </div>
                        }
                        @if (ViewBag.IsAdmin == true && ViewBag.anonymity == true)
                        {
                      <div id="all" class="tab-pane updateProfile">
                       <br />
                      <div style="text-align:center">
                        <label>姓名：</label>
                          <select name="selectname_ID" id="select_ID">
                                     <option value="1">全部</option>
                               @{
                              List<UserInfoViewModel> userListt = (List<UserInfoViewModel>)TempData["UserList"];
                                    if (userListt != null)
                                    {
                                        for (int i = 0; i < userListt.Count(); i++)
                                        {
                                            var item = userListt[i];
                                    <option value="@item.UserId">@item.UserName</option>
                                        }
                                    }
                                }
                          </select>
                        <label>时间：</label>
                        <div class="input-append date" style="display:inline-block"   id="selcet_BTime" data-date="@DateTime.Now.ToString("yyyy-MM-dd")" data-date-format="yyyy-mm-dd">
                                <input id="selcet_text_BTime_id"  name="selcet_text_BTime" size="10" type="text" value="@DateTime.Now.ToString("yyyy-MM-dd")"> 
                            <span class="add-on"><i  class="icon-th"></i></span>
                       </div>
                            <label style="display:inline-block" >-</label>
                       <div  class="input-append date"  style="display:inline-block"  id="selcet_DTime"  data-date="@DateTime.Now.ToString("yyyy-MM-dd")" data-date-format="yyyy-mm-dd">
                                <input  id="selcet_text_DTime_id"  name="selcet_text_DTime" size="10" type="text"  value="@DateTime.Now.ToString("yyyy-MM-dd")">
                             <span class="add-on"><i class="icon-th"></i></span>
                        </div>
                     <button onclick="selcet()">搜索</button>
                    </div>
                      <div id="YesSelcet" style="display:none" class="panel-body">
                                    <div id="xxx" class="table-responsive">
                                
                                       
                                    </div>
                                    <div class="bk-margin-5 btn-group" style="float: right">
                                        @Html.ShowPageNavigate((int)ViewData["pageIndexExecute"], (int)ViewData["pageSizeExecute"], (int)ViewData["totalFinish"])
                                    </div>
                      </div>
                      <div id="NoSelcet" class="panel-body">
                                    <div class="table-responsive">
                                    <hr style="width:100%; height:2px;border:none;border-top:2px solid #185598;"/>
                                        <table class="table table-hover">
                                            <thead>
                                                <tr>
                                                    <th style="text-align: center">请假人</th>
                                                    <th style="text-align: center">申请时间</th>
                                                    <th style="text-align: center">请假起止时间</th>
                                                    <th style="text-align: center">请假天数</th>
                                                    <th style="text-align: center">请假类别</th>
                                                    <th style="text-align: center">本月请假次数</th>
                                                    <th style="text-align: center">审批结果</th>
                                                    <th style="text-align: center">审批人</th>
                                                </tr>
                                            </thead>

                                            <tbody>
                                                @if (ViewBag.allLeave != null)
                                                {
                                                    foreach (ProjectDeskLeaveViewModel item in ViewBag.allLeave)
                                                    {
                                                    <tr>
                                                        
                                                       <td style="text-align: center;color: black">@item.leave_name</td>
                                              
                                                        <td style="text-align: center;color: black">@item.leave_time.ToString("yyyy-MM-dd")</td>
                                                        <td style="text-align: center;color: black">@item.leave_day</td>
                                                        <td style="text-align: center;color: black">@item.leave_howmanydays</td>
                                                        <td style="text-align: center;color: black">@item.leave_classes</td>
                                                        <td style="text-align: center;color: black">@item.leave_quantity</td>
                                                        @if (item.leave_approverresult == "0")
                                                        {
                                                            <td style="text-align: center;color: black">等待审批</td>
                                                        }
                                                        else
                                                        {
                                                            <td style="text-align: center;color: black">通过</td>
                                                        }
                                                        <td style="text-align: center;color: black">@item.leave_approver</td>
                                                    </tr>
                                                    }
                                                }
                                            </tbody>
                                        </table>
                                    </div>
                                    <div class="bk-margin-5 btn-group" style="float: right">
                                        @Html.ShowPageNavigate((int)ViewData["pageIndexFinish"], (int)ViewData["pageSizeFinish"], (int)ViewData["totalFinish"])
                                    </div>
                                </div>
                      </div>
                      <div id="dai" class="tab-pane updateProfile">
                                <div class="panel-body">
                                    <div class="table-responsive">
                                        <table class="table table-hover">
                                            <thead>
                                                <tr>
                                                    <th style="text-align: center">请假人</th>
                                                    <th style="text-align: center">申请时间</th>
                                                    <th style="text-align: center">请假起止时间</th>
                                                    <th style="text-align: center">请假天数</th>
                                                    <th style="text-align: center">请假类别</th>
                                          
                                                    <th style="text-align: center">审批操作</th>
                                          
                                                </tr>
                                            </thead>

                                            <tbody>
                                                @if (ViewBag.DAI != null)
                                                {
                                                    foreach (ProjectDeskLeaveViewModel item in ViewBag.DAI)
                                                    {
                                                    <tr>
                                                        
                                                       <td style="text-align: center;color: black">@item.leave_name</td>
                                              
                                                        <td style="text-align: center;color: black">@item.leave_time.ToString("yyyy-MM-dd")</td>
                                                        <td style="text-align: center;color: black">@item.leave_day</td>
                                                        <td style="text-align: center;color: black">@item.leave_howmanydays</td>
                                                        <td style="text-align: center;color: black">@item.leave_classes</td>
                                           
                                                        <td style="text-align: center;color: black">
                                                            <a onclick="leaveid('@item.leave_id')" data-toggle="modal" data-target="#leave_C" style="color:blue">&nbsp;&nbsp;详情&nbsp;&nbsp;</a>
                                                            <a onclick="daiid('@item.leave_id')" data-toggle="modal" data-target="#shenpi" style="color:blue">&nbsp;&nbsp;审批&nbsp;&nbsp;</a>
                                                        </td>
                                                    </tr>
                                                    }
                                                }
                                            </tbody>
                                        </table>
                                    </div>
                                    <div class="bk-margin-5 btn-group" style="float: right">
                                        @Html.ShowPageNavigate((int)ViewData["pageIndexExecute"], (int)ViewData["pageSizeExecute"], (int)ViewData["totalFinish"])
                                    </div>
                                </div>
                            </div>
                        }
                        @*匿名用户*@
                        @if (ViewBag.IsAdmin == true && ViewBag.anonymity == false)
                        {
                            <div id="all" class="tab-pane active">
                                <div class="panel-body">
                                    <div class="table-responsive">
                                        <table class="table table-hover">
                                            <thead>
                                                <tr>
                                                    <th style="text-align: center">请假人</th>
                                                    <th style="text-align: center">申请时间</th>
                                                    <th style="text-align: center">请假起止时间</th>
                                                    <th style="text-align: center">请假天数</th>
                                                    <th style="text-align: center">请假类别</th>
                                                    <th style="text-align: center">本月请假次数</th>
                                                    <th style="text-align: center">审批结果</th>
                                                    <th style="text-align: center">审批人</th>
                                                </tr>
                                            </thead>

                                            <tbody>
                                                @if (ViewBag.allLeave != null)
                                                {
                                                    foreach (ProjectDeskLeaveViewModel item in ViewBag.allLeave)
                                                    {
                                                    <tr>
                                                        @if (ViewBag.anonymity == true)
                                                        {
                                                            <td style="text-align: center;color: black"><a href="@Url.Action("Examine_Leave", "Leave", new { area = "DepartmentArea", projectId = item.leave_id })">@item.leave_name</a></td>
                                                        }
                                                        @if (ViewBag.anonymity == false)
                                                        {
                                                            <td style="text-align: center;color: black">@item.leave_name</td>
                                                        }
                                                        <td style="text-align: center;color: black">@item.leave_time.ToString("yyyy-MM-dd")</td>
                                                        <td style="text-align: center;color: black">@item.leave_day</td>
                                                        <td style="text-align: center;color: black">@item.leave_howmanydays</td>
                                                        <td style="text-align: center;color: black">@item.leave_classes</td>
                                                        <td style="text-align: center;color: black">@item.leave_quantity</td>
                                                        @if (item.leave_approverresult == "0")
                                                        {
                                                            <td style="text-align: center;color: black">等待审批</td>
                                                        }
                                                        else
                                                        {
                                                            <td style="text-align: center;color: black">通过</td>
                                                        }
                                                        <td style="text-align: center;color: black">@item.leave_approver</td>
                                                    </tr>
                                                    }
                                                }
                                            </tbody>
                                        </table>
                                    </div>
                                    <div class="bk-margin-5 btn-group" style="float: right">
                                        @Html.ShowPageNavigate((int)ViewData["pageIndexExecute"], (int)ViewData["pageSizeExecute"], (int)ViewData["totalFinish"])
                                    </div>
                                </div>
                            </div>
                        }
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>




<!-- 新增请假（Modal） -->

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <link href="~/Assets/plugins/bootstrap-select/bootstrap-select.min.css" rel="stylesheet" />
    <script src="~/Assets/plugins/bootstrap-select/bootstrap-select.min.js"></script>
    <link href="~/Assets/plugins/bootstrap-datepicker/css/datepicker3.css" rel="stylesheet" />
    <link href="~/Assets/plugins/bootstrap-datepicker/css/datepicker-theme.css" rel="stylesheet" />
    <script src="~/Assets/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
    <script src="~/Assets/plugins/chosen/chosen.jquery.min.js"></script>
    <script src="~/Assets/js/pages/form-elements.js"></script>
    <script src="~/Assets/js/jquery.validate.min.js"></script>
    <script>
        $(document).ready(function () {
            $("#leave_id").validate({
                rules: {
                    tb_leave_howmanydays: { required: true, digits: true, range: [1, 99] },
                    tb_leave_cause: { required: true },
                    tb_leave_approver: { required: true }
                },
                messages: {
                    tb_leave_howmanydays: { required: "请假天数不能为空", digits: "请假天数只能是整数", range: "请假天数只能是1-99的整数" },
                    tb_leave_cause: { required: "事由不能为空" },
                    tb_leave_approver: { required: "请填写审批人" },

                },
                errorPlacement: function (error, element) {
                    error.appendTo(element.next("span.leave_howmanydays_class"));
                    error.appendTo(element.next("span.leave_cause_class"));
                    error.appendTo(element.next("span.leave_approver_class"));
                },
            });
            $("span.leave_howmanydays_class").css("color", "red");
            $("span.leave_cause_class").css("color", "red");
            $("span.leave_approver_class").css("color", "red");
        })

        window.onload = function () {
             

            $("#kaishiriqi").datepicker({
                autoclose: true,
                pickerPosition: "bottom-right"
            });
            $("#datetime").datepicker({
                autoclose: true,
                pickerPosition: "bottom-right"
            });
            $("#BJ_kaishi").datepicker({
                autoclose: true,
                pickerPosition: "bottom-right"
            });
            $("#BJ_jieshu").datepicker({
                autoclose: true,
                pickerPosition: "bottom-right"
            });

            $("#selcet_BTime").datepicker({
                autoclose: true,
                pickerPosition: "bottom-right"
            });
            

            $("#selcet_DTime").datepicker({
                autoclose: true,
                pickerPosition: "bottom-right"
            });
        };

        function rili() {

            $.ajax({
                type: "POST",
                //url: "/KSManager/DepartmentArea/Leave/jisuan",
                url:'@Url.Action("jisuan","Leave",new{area="DepartmentArea"})',
                data: "BTime=" + $("#t_BTime").val() + "&&DTime=" + $("#t_DTime").val(),
                error: function () { alert("服务器出错！"); },
                success: function (data) {
                    $("#howmanydays_id").val(data["day"]);
                }
            });
        }
     
    
    </script>

    <style>
        .btn-default {
            color: #333;
            background-color: #FFF;
            border-color: #CCC;
            height: 34px;
        }

        .checknull {
            float: left;
        }
    </style>
    <div class="modal-dialog">
        <div class="modal-content">
            <form id="leave_id"  action="@Url.Action("ApplyForLeave", "Leave", new { area = "DepartmentArea" })" method="POST">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel">个人请假申请</h4>
                </div>
                <div id="div_CreateProject1" class="modal-body">
                    <div class="row">
                        <label class="col-md-3 control-label" for="text-input">申请人:</label>
                        <div class="col-md-9">
                            <input id="text-input2" readonly="true" value="@ViewBag.myName" style="border-color: cornflowerblue" name="tb_leave_name" class="form-control" placeholder="Text" type="text">
                        </div>
                    </div>
                    <br />

                    <div class="row">
                        <label class="col-md-3 control-label">开始日期：</label>
                        <div class="col-md-9">
                            <div class="input-append date" id="kaishiriqi" data-date="@DateTime.Now.ToString("yyyy-MM-dd")" data-date-format="yyyy-mm-dd">
                                <input onchange="rili()" id="t_BTime"  name="tb_BTime" style="border-color: cornflowerblue" class="form-control" size="10" type="text" value="@DateTime.Now.ToString("yyyy-MM-dd")">
                                <span class="add-on"><i class="icon-th"></i></span>
                            </div>
                            <span class="span_DevelopDescription"></span>
                        </div>
                    </div>
                         <br />

                      <div class="row">
                        <label class="col-md-3 control-label">结束日期：</label>
                        <div class="col-md-9">
                            <div class="input-append date" id="datetime" data-date="@DateTime.Now.ToString("yyyy-MM-dd")" data-date-format="yyyy-mm-dd">
                                <input onchange="rili()" name="tb_DTime" id="t_DTime" style="border-color: cornflowerblue" class="form-control" size="10" type="text" value="@DateTime.Now.ToString("yyyy-MM-dd")">
                                <span class="add-on"><i class="icon-th"></i></span>
                            </div>
                            <span class="span_DevelopDescription"></span>
                        </div>
                    </div>
                         <br />

                    <div class="row">
                        <label class="col-md-3 control-label">请假天数：</label>
                        <div class="col-md-9" style="max-height: 34px">
                            <input id="howmanydays_id" style="border-color: cornflowerblue" name="tb_leave_howmanydays" class="form-control" placeholder="Text" type="text">
                            <span class="leave_howmanydays_class"></span>
                        </div>

                    </div>

                    <br />

                    <div class="row">
                        <label class="col-md-3 control-label">请假类别：</label>
                        <div class="col-md-9" style="max-height: 34px">
                            <select name="select_leave_classes" class="form-control select2-active">
                                <option value="病假">病假</option>
                                <option value="事假">事假</option>
                                <option value="年假">年假</option>
                                <option value="婚丧假">婚丧假</option>
                                <option value="探亲假">探亲假</option>
                                <option value="产假">产假</option>
                            </select>
                        </div>
                    </div>
                    <br />
                    <div class="row">
                        <label class="col-md-3 control-label" for="text-input">请假事由：</label>
                        <div class="col-md-9">
                            <textarea id="textarea-input" name="tb_leave_cause" rows="5" class="form-control" placeholder="Content.."></textarea>
                            <span class="leave_cause_class"></span>
                        </div>
                    </div>
                    <br />
                    <div class="row">
                        <label class="col-md-3 control-label" for="text-input">审批人：</label>
                        <div class="col-md-9">
                            <select name="tb_leave_approver" id="select_ProjectLeader" class="form-control selectpicker">
                                @{
                                    List<UserInfoViewModel> userList = (List<UserInfoViewModel>)TempData["User"];
                                    if (userList != null)
                                    {
                                        for (int i = 0; i < userList.Count(); i++)
                                        {
                                            var item = userList[i];
                                    <option value="@item.UserId">@item.UserName</option>
                                        }
                                    }
                                }
                            </select>
                            <span class="leave_approver_class"></span>
                        </div>
                    </div>

                    <br />
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        关闭
                    </button>
                    <input type="submit" id="shenqing" value="申请" class="btn btn-primary" />
                </div>
            </form>
        </div>

    </div>

</div>



<script>
    function getid(bugId) {
        $.ajax({
            type: "POST",
            //url: "/KSManager/DepartmentArea/Leave/LeaveUpdat",
            url:'@Url.Action("LeaveUpdat","Leave",new{area="DepartmentArea"})',
            data: "roleId=" + bugId,
            error: function () { alert("服务器出错！"); },
            success: function (data) {
                $("#compile_leave_id").val(data["leave_id"]);
                $("#q_howmanydays_id").val(data["leave_howmanydays"]);
                $("#q_leave_causeid").val(data["leave_cause"]);
                $("#q_text_input").val(data["leave_approver"]);
                //$("#t_dtime").val(data["leave_end_day"]);
                //$("#t_btime").val(data["leave_begain_day"]);
            }
        });

    }

</script>
<!-- 编辑请假（Modal） -->
<div class="modal fade" id="q_bianji" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <link href="~/Assets/plugins/bootstrap-select/bootstrap-select.min.css" rel="stylesheet" />
    <script src="~/Assets/plugins/bootstrap-select/bootstrap-select.min.js"></script>
    <link href="~/Assets/plugins/bootstrap-datepicker/css/datepicker3.css" rel="stylesheet" />
    <link href="~/Assets/plugins/bootstrap-datepicker/css/datepicker-theme.css" rel="stylesheet" />
    <script src="~/Assets/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
    <script src="~/Assets/plugins/chosen/chosen.jquery.min.js"></script>
    <script src="~/Assets/js/pages/form-elements.js"></script>

    <script>

        $(document).ready(function () {
            $("#qing_leave_id").validate({
                rules: {
                    tb_leave_howmanydays: { required: true, digits: true, range: [1, 99] },
                    tb_leave_cause: { required: true },
                    tb_leave_approver: { required: true }
                },
                messages: {
                    tb_leave_howmanydays: { required: "请假天数不能为空", digits: "请假天数只能是整数", range: "请假天数只能是1-99的整数" },
                    tb_leave_cause: { required: "事由不能为空" },
                    tb_leave_approver: { required: "请填写审批人" },

                },
                errorPlacement: function (error, element) {
                    error.appendTo(element.next("span.leave_howmanydays_class"));
                    error.appendTo(element.next("span.leave_cause_class"));
                    error.appendTo(element.next("span.leave_approver_class"));
                },
            });
            $("span.leave_howmanydays_class").css("color", "red");
            $("span.leave_cause_class").css("color", "red");
            $("span.leave_approver_class").css("color", "red");
        })



        function bianji() {
            $.ajax({
                type: "POST",
                //url: "/KSManager/DepartmentArea/Leave/jisuan",
                url:'@Url.Action("jisuan","Leave",new{area="DepartmentArea"})',
                data: "BTime=" + $("#t_btime").val() + "&&DTime=" + $("#t_dtime").val(),
                error: function () { alert("服务器出错！"); },
                success: function (data) {
                    $("#q_howmanydays_id").val(data["day"]);
                }
            });
        
        }

    </script>


    <style>
        .btn-default {
            color: #333;
            background-color: #FFF;
            border-color: #CCC;
            height: 34px;
        }

        .checknull {
            float: left;
        }
    </style>
    <div class="modal-dialog">
        <div class="modal-content">
            <form id="qing_leave_id"  action="@Url.Action("updat_Leave", "Leave", new { area = "DepartmentArea" })" method="POST">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel">个人请假申请</h4>
                </div>
                <div id="div_CreateProject" class="modal-body">
                    <div class="row">
                        <label class="col-md-3 control-label" for="text-input">申请人:</label>
                        <div class="col-md-9">
                            <input id="text-input" readonly="true" value="@ViewBag.myName" style="border-color: cornflowerblue" name="tb_leave_name" class="form-control" placeholder="Text" type="text">
                            <input type="hidden" id="compile_leave_id" name="td_leavet_id" value="" />
                        </div>
                    </div>
                    <br />

                         <div class="row">
                        <label class="col-md-3 control-label">开始日期：</label>
                        <div class="col-md-9">
                            <div class="input-append date" id="BJ_kaishi" data-date="@DateTime.Now.ToString("yyyy-MM-dd")" data-date-format="yyyy-mm-dd">
                                <input onchange="bianji()" id="t_btime" name="tb_BTime" style="border-color: cornflowerblue" class="form-control" size="10" type="text" value="@DateTime.Now.ToString("yyyy-MM-dd")">
                                <span class="add-on"><i class="icon-th"></i></span>
                            </div>
                            <span class="span_DevelopDescription"></span>
                        </div>
                    </div>
                         <br />

                      <div class="row">
                        <label class="col-md-3 control-label">结束日期：</label>
                        <div class="col-md-9">
                            <div class="input-append date" id="BJ_jieshu" data-date="@DateTime.Now.ToString("yyyy-MM-dd")" data-date-format="yyyy-mm-dd">
                                <input onchange="bianji()" id="t_dtime" name="tb_DTime" style="border-color: cornflowerblue" class="form-control" size="10" type="text" value="@DateTime.Now.ToString("yyyy-MM-dd")">
                                <span class="add-on"><i class="icon-th"></i></span>
                            </div>
                            <span class="span_DevelopDescription"></span>
                        </div>
                    </div>
                         <br />



                    <div class="row">
                        <label class="col-md-3 control-label">请假天数：</label>
                        <div class="col-md-9" style="max-height: 34px">
                            <input id="q_howmanydays_id" style="border-color: cornflowerblue" name="q_leave_howmanydays" class="form-control" placeholder="Text" type="text">
                            <span class="leave_howmanydays_class"></span>
                        </div>

                    </div>

                    <br />

                    <div class="row">
                        <label class="col-md-3 control-label">请假类别：</label>
                        <div class="col-md-9" style="max-height: 34px">
                            <select name="q_select_leave_classes" class="form-control select2-active">
                                <option value="病假">病假</option>
                                <option value="事假">事假</option>
                                <option value="年假">年假</option>
                                <option value="婚丧假">婚丧假</option>
                                <option value="探亲假">探亲假</option>
                                <option value="产假">产假</option>
                            </select>
                        </div>
                    </div>
                    <br />
                    <div class="row">
                        <label class="col-md-3 control-label" for="text-input">请假事由：</label>
                        <div class="col-md-9">
                            <textarea id="q_leave_causeid" name="q_leave_cause" rows="5" class="form-control" placeholder="Content.."></textarea>
                            <span class="leave_cause_class"></span>
                        </div>
                    </div>
                    <br />
                    <div class="row">
                        <label class="col-md-3 control-label" for="text-input">审批人：</label>
                        <div class="col-md-9">
                            <select name="q_leave_approver" class="form-control selectpicker">
                                @{
                                    List<UserInfoViewModel> UserList = (List<UserInfoViewModel>)TempData["User"];
                                    if (UserList != null)
                                    {
                                        for (int i = 0; i < UserList.Count(); i++)
                                        {
                                            var item = UserList[i];
                                    <option value="@item.UserId">@item.UserName</option>
                                        }
                                    }
                                }
                            </select>
                            <span class="leave_approver_class"></span>
                        </div>
                    </div>

                    <br />
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        关闭
                    </button>
                    <input type="submit" id="shenqing" value="修改" class="btn btn-primary" />
                </div>
            </form>
        </div>

    </div>

</div>





<script>
    function deleteid(bugId) {

        $.ajax({
            type: "POST",
            //url: "/KSManager/DepartmentArea/Leave/documentDelete",
            url:'@Url.Action("documentDelete","Leave",new{area="DepartmentArea"})',
            data: "roleId=" + bugId,
            error: function () { alert("服务器出错！"); },
            success: function (data) {
                $("#delete_worktime_id").val(data["leave_id"]);
            }
        });
    }
</script>

<!-- 删除记录 模态框（Modal） -->
<div class="modal fade" id="Delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
            </div>
            <form enctype="multipart/form-data" action="@Url.Action("delete_Leave", "Leave", new { area = "DepartmentArea" })", method="POST" >

                <div class="modal-body">
                    <div class="row">
                        <label class="col-md-3 control-label" for="text-input">确定删除此项记录么</label>
                        <input type="hidden" id="delete_worktime_id" name="delete_worktime_idd" value="" />
                    </div>
                    <br />
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        关闭
                    </button>
                    <input type="submit" value="确定" class="btn btn-primary" />
                </div>

            </form>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal -->
</div>



@*审批ajax*@
<script>
    function daiid(bugId) {
        $.ajax({
            type: "POST",
            //url: "/KSManager/DepartmentArea/Leave/LeaveUpdat",
            url:'@Url.Action("LeaveUpdat","Leave",new{area="DepartmentArea"})',
            data: "roleId=" + bugId,
            error: function () { alert("服务器出错！"); },
            success: function (data) {
                $("#dai_leave_id").val(data["leave_id"]);
            }
        });
    }
</script>
<!-- 审批操作 模态框（Modal） -->
@*<div class="modal fade" id="shenpi" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
            </div>
            <form enctype="multipart/form-data" action="@Url.Action("LeaveOver", "Leave", new { area = "DepartmentArea" })", method="POST" >

                <div class="modal-body">
                    <div class="row">
                        <label class="col-md-3 control-label" for="text-input">确定审批此加班么？</label>
                        <input type="hidden" id="dai_leave_id" name="dai_leave_idd" value="" />
                    </div>
                    <br />
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        关闭
                    </button>
                    <input type="submit" value="确定" class="btn btn-primary" />
                </div>

            </form>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal -->
</div>*@

<div class="modal fade" id="shenpi" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel2">审批</h4>
            </div>
            <form action="@Url.Action("LeaveOver", "Leave", new { area = "DepartmentArea" })", method="POST">
                <div class="modal-body">
                 <input type="hidden" id="dai_leave_id" name="dai_leave_idd" value="" />
                    <div class="row">
                        <br />
                        <label class="col-md-3 control-label">工作状态操作：</label>
                        <div class="col-md-9">

                            <select name="select_LeaveStatus" class="form-control select2">
                                <option value="1">通过</option>
                                <option value="3">驳回</option>
                            </select>
                        </div>
                    </div>

                    <br />

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        关闭
                    </button>
                    <input type="submit" class="btn btn-primary" value="提交更改" />
                </div>
            </form>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal -->
</div>



<!-- 请假 模态框（Modal） -->
<script>
    function leaveid(bugId) {
        $.ajax({
            type: "POST",
            //url: "/KSManager/DepartmentArea/Leave/LeaveUpdat",
            url:'@Url.Action("LeaveUpdat","Leave",new{area="DepartmentArea"})',
            data: "roleId=" + bugId,
            error: function () { alert("服务器出错！"); },
            success: function (data) {
                $("#Q_leave_name").text(data["leave_name"]);
                $("#Q_leave_day").text(data["leave_day"]);
                $("#Q_day").text(data["leave_howmanydays"]);
                $("#Q_leave_classes").text(data["leave_classes"]);
                $("#Q_leave_cause").text(data["leave_cause"]);


            }
        });
    }
</script>


<div class="modal fade" id="leave_C" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <form id="Q_overtime_id" action="@Url.Action("updat_worktime", "Overtime", new { area = "DepartmentArea" })" method="POST">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabelQ">请假申请</h4>
                </div>
                <div id="div_CreateProjectQ" class="modal-body">
                    <div class="row">
                        <label class="col-md-3 control-label" for="text-input">申请人:</label>
                        <div class="col-md-9">
                            <label id="Q_leave_name" style="width: 100%" class="col-md-8 control-label" for="text-input"></label>
                        </div>
                    </div>
                    <br />

                    <div class="row">
                        <label class="col-md-3 control-label">请假起止日期：</label>
                        <div class="col-md-9">
                            <label id="Q_leave_day" style="width: 100%" class="col-md-8 control-label" for="text-input"></label>

                        </div>
                    </div>


                      <br />
                     <div class="row">
                        <label class="col-md-3 control-label" for="text-input">请假天数:</label>
                        <div class="col-md-9" style="height: 100%">
                            <label id="Q_day" style="width: 100%" class="col-md-8 control-label" for="text-input"></label>
                        </div>
                    </div>
                    <br />
                   <div class="row">
                        <label class="col-md-3 control-label" for="text-input">请假类别:</label>
                        <div class="col-md-9" style="height: 100%">
                            <label id="Q_leave_classes" style="width: 100%" class="col-md-8 control-label" for="text-input"></label>
                        </div>
                    </div>
                    <br />

                    <div class="row">
                        <label class="col-md-3 control-label" for="text-input">请假事由：</label>
                        <div class="col-md-9">
                            <label id="Q_leave_cause" style="width: 100%" class="col-md-8 control-label" for="text-input"></label>
                        </div>
                    </div>
                    <br />

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        关闭
                    </button>
                </div>
            </form>
        </div>

    </div>
</div>
 